<style>
<!--
.andonAttribute dt {
	width: 110px;
}

#enumTable span {
	position: static;
}
-->
</style>
<div class="pageContent">
	<form method="post" action="${rc.getContextPath()}/manage/andonAttribute/saveAndonAttribute" class="pageForm required-validate" onsubmit="return checkFormInput(this);">
		<div class="pageFormContent andonAttribute">
			<div style="width: 350px; float: left;">
				<input type="hidden" name="navTabId" value="${navTabId!''}"> <input type="hidden" name="id" value="<#if (andonAttribute.attributeText)??>${andonAttribute.attributeCode!''}</#if>">
				<fieldset>
					<dl class="nowrap ">
						<dt><@label key="andonAttributeCode.C,colon">ANDON属性编号：</@label></dt>
						<dd>
							<input name="attributeCode" value="<#if (andonAttribute.attributeCode)??>${andonAttribute.attributeCode!''}</#if>" size="22" type="text" maxlength="20" class="required  alphanumeric toUp" warn="<@label key='andonAttributeCode.C,alreadyExists'>ANDON属性编号已存在</@label>"<#if pattern!="add"> readonly="readonly" <#else> remote="${rc.getContextPath()}/manage/andonAttribute/validateAndonAttributeCode" </#if> />
						</dd>
					</dl>
					<dl class="nowrap">
						<dt><@label key="andonAttributeText.C,colon">ANDON属性描述：</@label></dt>
						<dd>
							<input name="attributeText" value="<#if (andonAttribute.attributeText)??>${andonAttribute.attributeText!''}</#if>" size="22" type="text" maxlength="60" class="required"<#if "view"==pattern> readonly="readonly" </#if> />
						</dd>
					</dl>
					<dl class="nowrap">
						<dt><@label key="andonAttributeType.C,colon">ANDON属性类型：</@label></dt>
						<dd>
							<#if ECode??&&(ECode?size>0)> <input type="hidden" name="valueTypeEcode" value="${andonAttribute.valueTypeEcode!''}" /> <select id="valueTypeEcode" class="required" value="${andonAttribute.valueTypeEcode!''}"<#if "add"!=pattern> disabled="disabled" </#if>> <#list ECode as eCode>
								<option value="${eCode.eCode!''}"<#if eCode.eCode==andonAttribute.valueTypeEcode> selected="selected" </#if> > ${eCode.eCodeText!''}</option> </#list>
							</select> </#if>
						</dd>
					</dl>
					<dl class="nowrap">
						<dt>&nbsp;</dt>
						<dd>
							<label><input type="checkbox" name="requiredFlag" value="1"<#if "view"==pattern> disabled="disabled" </#if> <#if (andonAttribute.requiredFlag)?? && (andonAttribute.requiredFlag == 1)> checked="true"</#if>><@label key="required.C">必填</@label></label>
						</dd>
					</dl>
					<dl class="nowrap">
						<dt>&nbsp;</dt>
						<dd>
							<label><input type="checkbox" name="lockFlag" value="1"<#if "view"==pattern> disabled="disabled" </#if> <#if (andonAttribute.lockFlag)?? && (andonAttribute.lockFlag == 1)> checked="true"</#if>><@label key="lock.C">锁定</@label></label>
						</dd>
					</dl>
					<dl style="width: 350px; height: 90px;">
						<dt><@label key='memo.C,colon'>备注：</@label></dt>
						<dd>
							<textarea style="width: 135px;" name="memo" maxlength="200" value="${andonAttribute.memo!''}" rows="4"><#if (andonAttribute.memo)??>${andonAttribute.memo!''}</#if></textarea>
						</dd>
					</dl>
				</fieldset>

			</div>

			<div id="rightPanel" style="float: left; width: 220px;
            &lt;#if andonAttribute.valueTypeECode??&amp;&amp;(andonAttribute.valueTypeECode=='enum') &gt;
            display:block;
            &lt;#else&gt;
            display:none;
            &lt;/#if&gt;
            ">
				<div class="panelBar">
					<ul class="toolBar" style="height: 25px;">
						<li style="width: 200px;"><a class="add" href="javascript:void(0);" onclick="_addRow();"> <span><@label key="add.B">新增</@label></span>
						</a></li>
					</ul>
				</div>
				<table id="enumTable"
					<#if "modify"==pattern>layoutH="210"<#else>layoutH="130"</#if> class="table canopration border" width="90%" >
					<thead>
                        <tr>
                            <th style="width:150px;"><@label key="Enumeration.C">枚举值</@label></th>
                            <th style="width:30px;"><@label key="opera.C">操作</@label></th>
                        </tr>
                    </thead>
                
                    <tBody id="enumTbody">
                    <#if andonAttribute.attributeEnumList??&&(andonAttribute.attributeEnumList?size>0) >
                        <#list andonAttribute.attributeEnumList as attributeEnum>
                            <tr>
                                <td style="padding-top:3px;">
                                    <input class="required" type='text' style='width:110px;height:19px;'name='attributeValue[${attributeEnum_index}]' value="${attributeEnum.attributeValue!''}" >
                                </td>
                                <td>
                                    <a title="<@label key='delete.B'>删除</@label>" class='btnDel' href='javascript:void(0)' onclick='_deleteRow(this);'>
                                        <@label key='delete.B'>删除</@label>
                                    </a>
                                </td>
                            </tr>
                        </#list>
                    </#if>
                    </tBody>
                </table>

			</div>
		</div>
		<#if andonAttribute??> <#assign createInfo=andonAttribute> <#include "/common/createInfo.html"> </#if>
		<div class="formBar">
			<ul>
				<#if pattern!="view">
				<li>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="submit"><@label key="save.B">保存</@label></button>
						</div>
					</div>
				</li>
				<li>
					<div class="buttonActiveGrey">
						<div class="buttonContent">
							<button type="button" class="close"><@label key="cancel.B">取消</@label></button>
						</div>
					</div>
				</li> <#else>
				<li>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="button" class="close"><@label key="close.B">关闭</@label></button>
						</div>
					</div>
				</li> </#if>
			</ul>
		</div>
	</form>

	<script>
function _addRow(){
	var statrtNum = $("#enumTable tbody tr", $.pdialog.getCurrent()).length;
    var gridTheadTh = $("#enumTable",  $.pdialog.getCurrent()).find("table thead th");
    var row="<tr><td style='width:"+$(gridTheadTh[0]).width()+"px;padding-top:3px;'><input type='text' class='required textInput'  style='width:110px;height:19px;'name='attributeValue["+statrtNum+"]' ></td>"+
    "<td style='width:"+$(gridTheadTh[1]).width()+"px;'>"+
    "<a title='"+"<@label key='delete.B'>删除</@label>'"+" class='btnDel' href='javascript:void(0)' onclick='_deleteRow(this);'><@label key='delete.B'>删除</@label></a></td></tr>";
    var tobdy=$("#enumTbody",$.pdialog.getCurrent());
    tobdy.append(row);
}

function _deleteRow(a){
    $(a).parents("tr").remove();
}
$(function(){
	var $page = DWZ.context();
    var $select=$("#valueTypeEcode", $page);
    var $rightPanel=$("#rightPanel", $page);
    if($select.value==="enum")
    {
        $rightPanel.css("display","block");
    }
    
    $select.change(function(){
 		$('[name=valueTypeEcode]', $page).val(this.value);
         if(this.value==='ENUM')
         {
             $rightPanel.css("display","block");
         }
         else
         {
        	 $("#enumTable tbody tr", $page).remove();
             $rightPanel.css("display","none");
         }
     }).change();
    
});
    
function checkFormInput(that)
{
	var $page = DWZ.context();
	var formCompleted=true;
    var $rightPanel=$("#rightPanel",$page);
    //若是枚举类型,验证枚举值填写是否完整
    if($rightPanel.css("display")==="block")
    {
         if($("#enumTable tbody tr", $page).length ===0)
         {
            formCompleted=false;
         }
    }
    
    if(formCompleted)
    {
    	var map = {};
        var repeat=false;
    	$("#enumTable tbody tr td:nth-child(1) input").each(function(){
    		if( this.value in map){
    			 repeat=true;
    			 return;
    		}else{
    			map[this.value] = this.value; 	
    		}
    	});
    	if(repeat){
    		 alertMsg.error("<@label key='enumValueCanNotRepeat.C'>枚举值不能重复！</@label>");
    		 return false;
    	}else{
    		 return validateCallback(that, dialogAjaxDone);
    	}
       
    }
    else
    {
        alertMsg.error("<@label key='enumValueCanNotNull.C'>枚举值不可为空！</@label>");
        return false;
    }
	 return validateCallback(that, dialogAjaxDone);
  
}
</script>